package br.com.treinaweb.parte1;

import android.app.Activity;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.ArrayAdapter;
import android.widget.Button;
import android.widget.Spinner;
import android.widget.TextView;

public class Tela7 extends Activity implements OnClickListener {
  private Spinner spnCursos;
  
  public void onCreate(Bundle savedInstanceState){
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_tela7);
    
    String[] cursos = getResources().getStringArray(R.array.cursos);
     ArrayAdapter<String> aAdapter = new ArrayAdapter<String>(this, android.R.layout.simple_gallery_item, cursos);
    
     spnCursos = (Spinner) findViewById(R.id.spinnerCursos);
     spnCursos.setAdapter(aAdapter);
     
    Button btnOk = (Button) findViewById(R.id.buttonOk);
    btnOk.setOnClickListener(this);
  }

  @Override
  public void onClick(View v) {
    // TODO Auto-generated method stub
    TextView resposta = (TextView) findViewById(R.id.textViewResposta);
    String msg = " Curso selecionado: ";
    msg += ((TextView) spnCursos.getSelectedView()).getText().toString();
    resposta.setText(msg);
  }

}
